/*********************************************************
 *
 * Filename: src/CMTimeShowWidget.cpp
 *   Author: jmdvirus
 *   Create: Sat 13 Jun 2020 02:52:58 PM CST
 *
 *********************************************************/

#include <iostream>
#include "CMTimeShowWidget.h"

CMTimeShowWidget::CMTimeShowWidget(QWidget *parent) : CMBaseWidget(parent) {
    m_font.setPointSize(40);
    m_back.setFont(m_font);
    m_back.setGeometry(m_winWidth / 8, 100, m_winWidth * 3 / 4, 200);
    m_back.setAlignment(Qt::AlignCenter);
    connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeShowSlot()));
}

CMTimeShowWidget::~CMTimeShowWidget() {
}

void CMTimeShowWidget::start() {
    m_timer.start(1000);
}

void CMTimeShowWidget::stop() {
    m_timer.stop();
}

void CMTimeShowWidget::timeShowSlot() {
    time_t now = time(NULL);
    struct tm *tm = localtime(&now);
    char text[32] = {0};
    strftime(text, sizeof(text), "%Y-%m-%d %H:%M:%S", tm);
    m_back.setText(text);
}

